<div class="layui-fluid" id="VIEW-user-info" lay-title="用户信息">
    <div class="layui-row layui-col-space10" action="">
        <div class="layui-card">
            <div class="layui-card-header">[ {{ current_user.login_name }} ] {{ current_user.nickname }}--信息编辑</div>
            <div class="layui-card-body">
                <form class="layui-form" action="" lay-filter="form-user-info">
                    <div class="layui-row layui-form-item">
                        <div class="layui-col-lg4">
                            <label class="layui-form-label">昵称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="nickname" lay-verify="required" placeholder="请输入您的昵称"
                                       autocomplete="off" class="layui-input" value="{{ current_user.nickname }}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-row layui-form-item">
                        <div class="layui-col-lg4">
                            <label class="layui-form-label">性别：</label>
                            <div class="layui-input-block">
                                {% if current_user.sex==1 %}
                                <input type="radio" name="sex" value="1" title="男" checked>
                                <input type="radio" name="sex" value="2" title="女">
                                {% else %}
                                <input type="radio" name="sex" value="1" title="男">
                                <input type="radio" name="sex" value="2" title="女" checked>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                    <div class="layui-row layui-form-item">
                        <div class="layui-col-lg4">
                            <label class="layui-form-label">手机号：</label>
                            <div class="layui-input-block">
                                <input type="tel" name="mobile" placeholder="请输入您的手机号" lay-verify="phone"
                                       autocomplete="off" class="layui-input" value="{{ current_user.mobile }}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-row layui-form-item">
                        <div class="layui-col-lg4">
                            <label class="layui-form-label">邮箱地址：</label>
                            <div class="layui-input-block">
                                <input type="text" name="email" placeholder="请输入您的邮箱地址" lay-verify="email"
                                       autocomplete="off" class="layui-input" value="{{ current_user.email }}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="usr-edit-submit">
                                <i style="display: none"
                                   class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i>
                                保存修改
                            </button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['admin', 'form', 'jquery'], function (admin, form, $) {
        var view = $('#VIEW-user-info');
        form.render(null, 'form-user-info');
        view.find('[name=nickname]').focus();

        //保存信息
        form.on('submit(usr-edit-submit)', function (data) {
            var loading = $(this).find('.layui-icon');
            if (loading.is(":visible")) return;

            admin.post({
                api: 'userEdit',
                data: data.field,
                success: function (res) {
                    if (res.code == 200) {
                        //layer.msg(res.msg, {icon: 1});
                        admin.modal['success'](res.msg);

                        loading.css('display', 'none');
                        view.find('[name=nickname]').focus();
                    }
                },
                complete: function () {
                    //loading.hide();
                    //console.log('over');
                }
            });

            return false;
        });

    })
</script>